<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class GenerateSeeder extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'generate:seeder {--history}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'generate a seeder';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $isHistory = $this->option('history');

        if($isHistory) {
            $this->history();
            $this->info('finish history done!!');
            return;
        }
        $this->statics();
        $this->info('finish statics done!!');
    }

    /**
     * 
     */
    protected function statics() {
        $tables=['menus', 'sy_user', 'sy_area', 'abilities', 'assigned_roles', 'permissions', 'roles', 't_devicetype', 't_companycnfo', 't_prideviceinfo'];
        $this->call('iseed', [
            'tables'=>implode(',', $tables),
            '--force' => true,
        ]);
    }


    protected function History() {
        $tables=['t_hisdata_three', 't_hisdata_ACSta', 't_hisdata_generalair', 't_hisdata_BatRout', 't_hisdata_Switch', 't_hisdata_single',  't_hisdata_power', 't_hisdata_Generator', 't_hisdata_TempHumi'];
        $this->call('iseed', [
            'tables'=>implode(',', $tables),
            '--force' => true,
            '--max' => 10,
            '--orderby' => 'hd_datetime',
            '--direction' => 'desc',
        ]);
    }
}
